// (Geometry: area of a triangle) Write a program that prompts the user to enter 
// three points (x1, y1), (x2, y2), (x3, y3) of a triangle and displays its area. 
// The formula for computing the area of a triangle is
// s = (side1 + side2 + side3)/2;
// area = 2s(s - side1)(s - side2)(s - side3)

import java.util.Scanner;

public class test219 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        
        // 提示用户输入三个点的坐标
        System.out.print("Enter three points for a triangle (x1 y1 x2 y2 x3 y3): ");
        double x1 = input.nextDouble();
        double y1 = input.nextDouble();
        double x2 = input.nextDouble();
        double y2 = input.nextDouble();
        double x3 = input.nextDouble();
        double y3 = input.nextDouble();
        
        // 计算三条边的长度
        double side1 = Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2));
        double side2 = Math.sqrt(Math.pow(x3 - x2, 2) + Math.pow(y3 - y2, 2));
        double side3 = Math.sqrt(Math.pow(x1 - x3, 2) + Math.pow(y1 - y3, 2));
        
        // 计算半周长
        double s = (side1 + side2 + side3) / 2;
        
        // 使用海伦公式计算面积
        double area = Math.sqrt(s * (s - side1) * (s - side2) * (s - side3));
        
        // 显示结果，保留两位小数
        System.out.printf("The area of the triangle is %.2f", area);
        
        input.close();
    }
}
